package org.csmzclass2333;
import java.util.Scanner;
public class example04 {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);

            System.out.print("请输入第一个正整数: ");
            int num1 = scanner.nextInt();

            System.out.print("请输入第二个正整数: ");
            int num2 = scanner.nextInt();

            int gcd = calculateGCD(num1, num2);
            int lcm = calculateLCM(num1, num2, gcd);

            System.out.println("最大公约数是: " + gcd);
            System.out.println("最小公倍数是: " + lcm);

            scanner.close();
        }

        // 计算最大公约数的方法
        public static int calculateGCD(int a, int b) {
            while (b != 0) {
                int temp = b;
                b = a % b;
                a = temp;
            }
            return a;
        }

        // 计算最小公倍数的方法
        public static int calculateLCM(int a, int b, int gcd) {
            return (a * b) / gcd;
        }
    }
